Conversation
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new adaptive regularization scheme (MaternAdaptiveBrightnessKernel) that combines Matérn kernel-based regularization with brightness-adaptive weights, enabling spatially varying smoothness in pixelized inversions. The implementation is designed to work with both NumPy and JAX backends and includes optimizations for Delaunay triangulation when area calculations are not needed.
Changes:
- Added
MaternAdaptiveBrightnessKernelclass with brightness-adaptive weighting for Matérn regularization - Introduced backend-agnostic
gamma_xpfunction and relaxed type constraints inMaternKernelfor improved backend compatibility - Added minimal Delaunay triangulation functions and
skip_areasflag to optimize performance when Voronoi areas are not required
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
autoarray/inversion/regularization/matern_adaptive_brightness_kernel.py |
New adaptive Matérn regularization class with brightness-dependent weights and weighted covariance matrix construction |
autoarray/inversion/regularization/__init__.py |
Registered the new MaternAdaptiveBrightnessKernel class for import |
autoarray/inversion/regularization/matern_kernel.py |
Added backend-agnostic gamma_xp function and relaxed type casting for scale/nu parameters |
autoarray/structures/mesh/delaunay_2d.py |
Added minimal Delaunay functions for Matérn usage and implemented skip_areas flag logic |
autoarray/preloads.py |
Added skip_areas parameter to control Delaunay area computation |
autoarray/structures/arrays/kernel_2d.py |
Fixed parameter annotation spacing |
test_autoarray/inversion/regularizations/test_matern_adaptive_brightness_kernel.py |
Comprehensive tests for the new regularization scheme |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
autoarray/inversion/regularization/matern_adaptive_brightness_kernel.py
Outdated
Show resolved
Hide resolved
autoarray/inversion/regularization/matern_adaptive_brightness_kernel.py
Outdated
Show resolved
Hide resolved
autoarray/inversion/regularization/matern_adaptive_brightness_kernel.py
Outdated
Show resolved
Hide resolved
| linear_light_profile_blurred_mapping_matrix=None, | ||
| use_voronoi_areas: bool = True, | ||
| areas_factor: float = 0.5, | ||
| skip_areas: bool = False, |
There was a problem hiding this comment.
The newly added skip_areas parameter is not documented in the Parameters section of the Preloads docstring. Please add documentation explaining what this parameter controls, when it should be set to True, and how it affects the Delaunay triangulation computation (specifically that it skips Voronoi area calculations and split point computations).
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
test_autoarray/inversion/regularizations/test_matern_adaptive_brightness_kernel.py
Outdated
Show resolved
Hide resolved
| coefficient | ||
| The regularization coefficient which controls the degree of smooth of the inversion reconstruction. | ||
| scale | ||
| The typical scale of the exponential regularization pattern. |
There was a problem hiding this comment.
The parameter description refers to "exponential regularization pattern" but this class implements a Matérn kernel regularization. The description should refer to "Matérn regularization pattern" for accuracy. While the parent class has the same issue, it should be corrected in this new class.
| The typical scale of the exponential regularization pattern. | |
| The typical scale of the Matérn regularization pattern. |
autoarray/inversion/regularization/matern_adaptive_brightness_kernel.py
Outdated
Show resolved
Hide resolved
| mesh_grid = aa.m.MockMeshGrid(neighbors=neighbors, neighbors_sizes=neighbors_sizes) | ||
|
|
There was a problem hiding this comment.
Variable mesh_grid is not used.
| mesh_grid = aa.m.MockMeshGrid(neighbors=neighbors, neighbors_sizes=neighbors_sizes) | |
…kernel.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…kernel.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…kernel.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@Jammy2211 I've opened a new pull request, #215, to work on those changes. Once the pull request is ready, I'll request review from you. |
…brightness_kernel.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… parameters Co-authored-by: Jammy2211 <23455639+Jammy2211@users.noreply.github.com>
Document skip_areas parameter in Preloads docstring
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…kernel.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces a new adaptive regularization scheme based on a Matérn kernel that adapts to pixel brightness, along with supporting infrastructure for efficient computation and testing. The main focus is to enable more flexible, data-driven regularization in pixelized inversions, particularly for use cases that benefit from spatially adaptive smoothing. Additionally, several utility and interface improvements were made to support the new regularization and enhance backend compatibility.
New adaptive Matérn kernel regularization:
MaternAdaptiveBrightnessKernelclass inmatern_adaptive_brightness_kernel.py, which implements a Matérn kernel regularization scheme where per-pixel weights adapt to the reconstructed brightness, enabling spatially varying smoothing. Includes methods for constructing the covariance matrix and computing weights, as well as detailed documentation.__init__.pyfor import.test_matern_adaptive_brightness_kernel.py.Backend and kernel improvements:
gamma_xp), ensuring compatibility with both NumPy and JAX. [1] [2]MaternKernelto allow for non-float parameters, improving flexibility and backend support.Delaunay triangulation enhancements for Matérn regularization:
scipy_delaunay_matern,jax_delaunay_matern) optimized for Matérn regularization, returning only the necessary information for downstream computation.skip_areasflag. [1] [2]skip_areasflag to thePreloadsclass to allow this optimization to be configured. [1] [2]